﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace LinqToAmazonSilverlightUI.DataTypesUI
{
    public enum Field
    {
        KeyTitle,
        KeySignIn,
        KeyChangeUsed,
        Search,
        LinkLanguage,
        LinkSearchAdvanced,
        LinkSearchBasic,
        AdvancedTitle,
        AdvancedSortBy,
        AdvancedFilteredBy,
        FilterAuthor,
        FilterPublisher,
        FilterTitle,
        FilterCategory,
        FilterLiteratureFiction,
        FilterMedicine,
        FilterMysteryThrillers,
        FilterNonfiction,
        FilterNature,
        FilterConditions,
        FilterConditionAll,
        FilterConditionNew,
        FilterConditionUsed,
        FilterConditionCollectible,
        FilterConditionRefurbished,
        FilterKeyword,
        FilterMaximumPrice,
        FilterMinimumPrice,
        AdvancedSortFirst,
        AdvancedSortSecond,
        AdvancedSortThird,
        AdvancedSortListPrice,
        AdvancedSortPriceAscending,
        AdvancedSortPriceDescending,
        AdvancedSortPublication,
        AdvancedSortTitle,
        AdvancedClean,
        PaginatedPageOf,
        PaginatedPageNoResult,
        SearchLoading,
        InvalidKey
    }

    public class TextLanguage
    {
        public int IdentifyLanguage { get; set; }
        
        public TextLanguage()
        {
            //By default: English
            IdentifyLanguage = 1;
        }

        public string GetText(Field field)
        {
            string text = "";
            switch (this.IdentifyLanguage)//language
            {
                case 1:
                    text = GetTextEnglish(field);
                    break;
                case 2:
                    text = GetTextSpanish(field);
                    break;
            }
            return text;
        }

        private static string GetTextEnglish(Field field)
        {
            string text = "";

            switch (field)
            {
                case Field.KeyTitle:
                    text = "Amazon Key";
                    break;
                case Field.KeySignIn:
                    text = "Sign In";
                    break;
                case Field.KeyChangeUsed:
                    text = "Change Key Used";
                    break;
                case Field.Search:
                    text = "Search";
                    break;
                case Field.LinkLanguage:
                    text = "Español";
                    break;
                case Field.LinkSearchAdvanced:
                    text = "Advanced Search";
                    break;
                case Field.LinkSearchBasic:
                    text = "Basic Search";
                    break;                
                case Field.PaginatedPageOf:
                    text = "of";
                    break;
                case Field.PaginatedPageNoResult:
                    text = "... No Result ...";
                    break;
                case Field.SearchLoading:
                    text = "Loading...";
                    break;
                case Field.InvalidKey:
                    text = "Invalid key";
                    break;
                default:
                    text = GetTextAdvEnglish(field);
                    break;
            }
            return text;

        }

        private static string GetTextAdvEnglish(Field field)
        {
            string text = "";

            switch (field)
            {
                case Field.AdvancedTitle:
                    text = "Advanced Search";
                    break;
                case Field.AdvancedSortBy:
                    text = "Sort by";
                    break;
                case Field.AdvancedFilteredBy:
                    text = "Filtered by";
                    break;
                case Field.AdvancedClean:
                    text = "clean";
                    break;
                default:
                    text = GetTextAdvFiltEnglish(field);
                    if (string.IsNullOrEmpty(text))
                    {
                        text = GetTextAdvSortEnglish(field);
                    }
                    break;
            }
            return text;
        }

        private static string GetTextAdvFiltEnglish(Field field)
        {
            string text = "";

            switch (field)
            {
                case Field.FilterAuthor:
                    text = "Author:";
                    break;
                case Field.FilterPublisher:
                    text = "Publisher:";
                    break;
                case Field.FilterTitle:
                    text = "Title:";
                    break;
                case Field.FilterCategory:
                    text = "Category:";
                    break;
                case Field.FilterLiteratureFiction:
                    text = "Literature and Fiction";
                    break;
                case Field.FilterMedicine:
                    text = "Medicine";
                    break;
                case Field.FilterMysteryThrillers:
                    text = "Mystery and Thrillers";
                    break;
                case Field.FilterNonfiction:
                    text = "Nonfiction";
                    break;
                case Field.FilterNature:
                    text = "Nature and Outdoors";
                    break;
                case Field.FilterConditions:
                    text = "Condition:";
                    break;
                case Field.FilterConditionAll:
                    text = "All";
                    break;
                case Field.FilterConditionNew:
                    text = "New";
                    break;
                case Field.FilterConditionUsed:
                    text = "Used";
                    break;
                case Field.FilterConditionCollectible:
                    text = "Collectible";
                    break;
                case Field.FilterConditionRefurbished:
                    text = "Refurbished";
                    break;
                case Field.FilterKeyword:
                    text = "Keyword:";
                    break;
                case Field.FilterMaximumPrice:
                    text = "Max. Price (U$S):";
                    break;
                case Field.FilterMinimumPrice:
                    text = "Min. Price (U$S):";
                    break;
            }
            return text;
        }

        private static string GetTextAdvSortEnglish(Field field)
        {
            string text = "";

            switch (field)
            {
                case Field.AdvancedSortFirst:
                    text = "First by:";
                    break;
                case Field.AdvancedSortSecond:
                    text = "Second by:";
                    break;
                case Field.AdvancedSortThird:
                    text = "Third by:";
                    break;
                case Field.AdvancedSortListPrice:
                    text = "List Price";
                    break;
                case Field.AdvancedSortPriceAscending:
                    text = "ascending";
                    break;
                case Field.AdvancedSortPriceDescending:
                    text = "descending";
                    break;
                case Field.AdvancedSortPublication:
                    text = "Publication";
                    break;
                case Field.AdvancedSortTitle:
                    text = "Title";
                    break;
            }
            return text;
        }



        private static string GetTextSpanish(Field field)
        {
            string text = "";

            switch (field)
            {
                case Field.KeyTitle:
                    text = "Clave de Amazon";
                    break;
                case Field.KeySignIn:
                    text = "Registrarse";
                    break;
                case Field.KeyChangeUsed:
                    text = "Usar otra clave";
                    break;
                case Field.Search:
                    text = "Buscar";
                    break;
                case Field.LinkLanguage:
                    text = "English";
                    break;                
                case Field.LinkSearchAdvanced:
                    text = "Búsqueda Avanzada";
                    break;
                case Field.LinkSearchBasic:
                    text = "Búsqueda Básica";
                    break;                
                case Field.PaginatedPageOf:
                    text = "de";
                    break;
                case Field.PaginatedPageNoResult:
                    text = "... Ningún resultado ...";
                    break;
                case Field.SearchLoading:
                    text = "Cargando...";
                    break;
                case Field.InvalidKey:
                    text = "Clave inválida";
                    break;
                default:
                    text = GetTextAdvSpanish(field);
                    break;
            }
            return text;
        }

        private static string GetTextAdvSpanish(Field field)
        {
            string text = "";

            switch (field)
            {                
                case Field.AdvancedTitle:
                    text = "Búsqueda Avanzada";
                    break;
                case Field.AdvancedSortBy:
                    text = "Ordenar por";
                    break;
                case Field.AdvancedFilteredBy:
                    text = "Filtrar por";
                    break;
                case Field.AdvancedClean:
                    text = "limpiar";
                    break;
                default:
                    text = GetTextAdvFiltSpanish(field);
                    if (string.IsNullOrEmpty(text))
                    {
                        text = GetTextAdvSortSpanish(field);
                    }
                    break;
            }
            return text;
        }

        private static string GetTextAdvFiltSpanish(Field field)
        {
            string text = "";

            switch (field)
            {   
                case Field.FilterAuthor:
                    text = "Autor:";
                    break;
                case Field.FilterPublisher:
                    text = "Editorial:";
                    break;
                case Field.FilterTitle:
                    text = "Título:";
                    break;
                case Field.FilterCategory:
                    text = "Categoría:";
                    break;
                case Field.FilterLiteratureFiction:
                    text = "Literatura y Ficción";
                    break;
                case Field.FilterMedicine:
                    text = "Medicina";
                    break;
                case Field.FilterMysteryThrillers:
                    text = "Misterio y Suspenso";
                    break;
                case Field.FilterNonfiction:
                    text = "No ficción";
                    break;
                case Field.FilterNature:
                    text = "Naturaleza y Exterior";
                    break;
                case Field.FilterConditions:
                    text = "Condición:";
                    break;
                case Field.FilterConditionAll:
                    text = "Todos";
                    break;
                case Field.FilterConditionNew:
                    text = "Nuevo";
                    break;
                case Field.FilterConditionUsed:
                    text = "Usado";
                    break;
                case Field.FilterConditionCollectible:
                    text = "Coleccionable";
                    break;
                case Field.FilterConditionRefurbished:
                    text = "Restaurado";
                    break;
                case Field.FilterKeyword:
                    text = "Clave:";
                    break;
                case Field.FilterMaximumPrice:
                    text = "Precio Máx. (U$S):";
                    break;
                case Field.FilterMinimumPrice:
                    text = "Precio Mín. (U$S):";
                    break;                
            }
            return text;
        }

        private static string GetTextAdvSortSpanish(Field field)
        {
            string text = "";

            switch (field)
            {
                case Field.AdvancedSortFirst:
                    text = "Primero:";
                    break;
                case Field.AdvancedSortSecond:
                    text = "Segundo:";
                    break;
                case Field.AdvancedSortThird:
                    text = "Tercero:";
                    break;
                case Field.AdvancedSortListPrice:
                    text = "Precio";
                    break;
                case Field.AdvancedSortPriceAscending:
                    text = "ascendente";
                    break;
                case Field.AdvancedSortPriceDescending:
                    text = "descendente";
                    break;
                case Field.AdvancedSortPublication:
                    text = "Publicación";
                    break;
                case Field.AdvancedSortTitle:
                    text = "Título";
                    break;                
            }
            return text;
        }

        public string GetTextItemResult(string nameCtrl)
        {
            if (IdentifyLanguage == 1)
            {
                return GetTextItemResultEn(nameCtrl);
            }
            else
            {
                return GetTextItemResultEs(nameCtrl);
            }
        }

        private static string GetTextItemResultEn(string nameCtrl)
        {
            string text = "";

            switch (nameCtrl)
            {
                //Info
                case "lblRsltPublisher":
                    text = "Publisher";
                    break;
                case "lblRsltPrice":
                    text = "Price: ";
                    break;

                //Mre Info
                case "lblRsltMIPublisher":
                    text = "Publisher";
                    break;
                case "lblRsltMIPrice":
                    text = "Price: ";
                    break;
                case "lblRsltMILwstPrices":
                    text = "Lowest Prices";
                    break;
                case "lblRsltMILPNew":
                    text = "New: ";
                    break;
                case "lblRsltMILPUsed":
                    text = "Used: ";
                    break;
                case "lblRsltMILPCollectible":
                    text = "Collectible: ";
                    break;
                case "lblRsltMIPubDDate":
                    text = "Publication Date ";
                    break;
                case "lblRsltMIRelDate":
                    text = "Release Date ";
                    break;
                case "lblRsltMIISBN":
                    text = "ISBN ";
                    break;
            }

            return text;
        }

        private static string GetTextItemResultEs(string nameCtrl)
        {
            string text = "";

            switch (nameCtrl)
            {
                //Info
                case "lblRsltPublisher":
                    text = "Editorial";
                    break;
                case "lblRsltPrice":
                    text = "Precio: ";
                    break;

                //Mre Info
                case "lblRsltMIPublisher":
                    text = "Editorial";
                    break;
                case "lblRsltMIPrice":
                    text = "Precio: ";
                    break;
                case "lblRsltMILwstPrices":
                    text = "Precios más bajos";
                    break;
                case "lblRsltMILPNew":
                    text = "Nuevo: ";
                    break;
                case "lblRsltMILPUsed":
                    text = "Usado: ";
                    break;
                case "lblRsltMILPCollectible":
                    text = "Coleccionable: ";
                    break;
                case "lblRsltMIPubDDate":
                    text = "Publicación ";
                    break;
                case "lblRsltMIRelDate":
                    text = "Liberado ";
                    break;
                case "lblRsltMIISBN":
                    text = "ISBN ";
                    break;
            }
            return text;
        }

    }
}
